$(function(){	
    
	$("#getCode").click(function(){
		$(this).attr("src",'vcode/code_num.php?' + Math.random());
	});
	
	
	//点发送邮件
	$("#sendMailButton").click(function(){
		sendMail()
	});
	
	function sendMail(){
		var email = $.trim($("#email").val());
		var vCode = $.trim($("#vCode").val());
		
		if (email == '' || email == '请输入登录邮箱') {
			
		} else if (!tools.isEmail(email)) {
			$("#error").html('登录邮箱输入不正确') ;		
		} else if (vCode == '' || vCode.length != 4) {
			$("#error").html('验证码不正确') ;	
		} else {								
			var url = "service/forgotpass.php";
			var requestData = JSON.stringify({
    		"cmd":"forgotpass","email":email,"vCode":vCode
			});
			$.ajax({
				type:"POST",
				url: url,
				cache: false,
				async: false,
				data: requestData,
				dataType: 'json',
				success: function(resp) {
					alert(resp.code);
					if (resp.code == '0') {	
						window.location.href = 'index.php' ;
					}else{
						$("#getCode").attr("src",'vcode/code_num.php?' + Math.random());
					}
				}
			});
		}
	}

});
 